﻿using System.Drawing;
using System.Drawing.Imaging;
using System.IO;

namespace CloudShot.Utils
{
  public static class ImageSaveUtils
  {
    public static void SafeSave(this Image image, string path, ImageFormat format)
    {
      using (var ms = new MemoryStream())
      using (var fs = new FileStream(path, FileMode.Create))
      {
        image.Save(ms, format);
        ms.WriteTo(fs);
      }
    }
  }
}